home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0085_Julia Set.pas < prev    next >
Pascal/Delphi Source File  |  1994-01-27  |  1KB  |  59 lines

  1. {
  2.  To try out the program, some complex constants you can
  3.  use are -1, -0.1+0.8i, 0.3-0.5i, -1.139+0.238i.  ie, when
  4.  asked for the real part, enter 0.3.  For the imaginary,
  5.  enter -.5 }
  6.  
  7. program julia;
  8. {$N+,E+}
  9. uses crt;
  10. Type Real = double;
  11. var  cx, cy, xo, yo, x1, y1 : real;
  12.      mx, my, a, b, i, orb   : word;
  13.  
  14. label XXX;
  15.  
  16. procedure pset ( rx, ry: real; c:byte );
  17. var a, x, y :word;
  18. begin
  19.   x := round(rx);
  20.   y := round(ry);
  21.   a := 320* pred(y) + x;
  22.   mem[$A000:A] := c
  23. end;
  24. begin
  25.   write('Real part: ');
  26.   readln(CX);
  27.   write('Imaginary part: ');
  28.   readln(CY);
  29.   asm
  30.     mov ax, $13
  31.     int 10h
  32.   end;
  33.   MX := 319; {  ' the box we want to plot on the screen }
  34.   MY := 199;
  35.   FOR A := 1 TO MX  do    {'X screen coordinate}
  36.     FOR B := 1 TO MY do   {'Y screen coordinate  }
  37.     begin
  38.       XO := -2 + A / (MX / 4); {'X complex plane coordinate}
  39.       YO :=  2 - B / (MY / 4);  {'Y complex plane coordinate}
  40.       Orb := 0;
  41.       FOR I := 1 TO 255 do     {'iterations for 255 colors}
  42.       begin
  43.         X1 := XO * XO - YO * YO + CX;
  44.         Y1 := 2 * XO * YO + CY;
  45.         IF X1 * X1 + Y1 * Y1 > 4.0 THEN  {'orbit escapes, plot it}
  46.         begin
  47.           Orb := I;
  48.           GOTO XXX;
  49.         END;
  50.         XO := X1;
  51.         YO := Y1;
  52.       end;
  53. XXX:
  54.       PSET (A, B, Orb);  { 'plot orbit}
  55.     end;
  56.   readln;
  57.   textmode(lastmode);
  58. end.
  59.